package main

import (
	"encoding/json"
	"fmt"
)

type Foo struct {
	Name    string
	Age     int
	Parents []string
}

func main() {
	bytes, err := json.Marshal(buildData())

	if err != nil {
		return
	}

	js := string(bytes)
	fmt.Println(js)

	var foo Foo
	err = json.Unmarshal(bytes, &foo)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(foo)
}

func buildData() map[string]interface{} {
	m := map[string]interface{}{
		"Name": "Wednesday",
		"Age":  6,
		"Parents": []interface{}{
			"Gomez",
			"Morticia",
		},
	}
	return m
}
